package com.oa.office.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.oa.office.biz.SharBiz;
import com.oa.office.entity.Shar;

@Controller
@RequestMapping("shar")
public class SharController {
	@Resource
	private SharBiz sharBiz;
	
	@RequestMapping("findAll")
	public String findAll(Model model){
		List<Shar> sharList=sharBiz.selectAllShar();
		model.addAttribute("sharList", sharList);
		return "office/shar";
	}
	
	@RequestMapping("findById/{id}")
	public String selectSharById(@PathVariable("id") Integer id,Model model){
		Shar shar = sharBiz.selectByPrimaryKey(id);
		model.addAttribute("shar", shar);
		return "office/sharContent";
	}
	
	@RequestMapping("waitAdd")
	public String waitAdd(){
		return "office/sharAdd";
	}
	
	@RequestMapping("add")
	public String add(Shar shar,Model model){
		sharBiz.insertSelective(shar);
		return findAll(model);
	}
	
}
